//获取应用实例
var app = getApp()
var interval;
var varName;
var ctx = wx.createCanvasContext('canvasArcCir');
var utils = require('../../utils/util.js');
var httpUrl = getApp().globalData.httpUrl;
Page({
    data: {},
    onLoad: function(options) {
        var that = this;
        
        that.oNslideList();
        that.oNmemberInfo();
        that.oNnewList();
        that.oNmyStateInfo();
    },
    onShow:function(e){
        var that=this;
        that.setData({
            userAvatarUrl: wx.getStorageSync("userInfo").avatarUrl
        })
        that.oNmyhealth();
    },
    //轮播图列表
    oNslideList: function(e) {
        var that = this;
        utils.http(httpUrl + "/mobile/Common/slide", {}, function(res) {
            if (res.state == 1) {
                // console.log(res);
                that.setData({
                    slideList: res.datas
                });
            } else {
               // utils.message(res.datas);
            }
        })
    },
    //点击轮播图进入新闻
    onSwiperTap:function(e){
        var that = this;
        wx.navigateTo({
            url: '../newmore/newmoreDetail/newmoreDetail?id=' + e.currentTarget.dataset.id + "&type=" + e.currentTarget.dataset.type
        })
    },
    //我的训练
    oNmemberInfo: function(e) {
        var that = this;
        utils.http(httpUrl + "/mobile/member/member_info", {}, function(res) {
            if (res.state == 1) {
                that.setData({
                    datainfo: res.datas
                })
            } else {
               // utils.message(res.datas)
            }
        })
    },
    //首页新闻列表
    oNnewList: function(e) {
        var that = this;
        utils.http(httpUrl + "/mobile/notice/index", {}, function(res) {
            if (res.state == 1) {
                that.setData({
                    newList: res.datas
                })
            } else {
               // utils.message(res.datas)
            }
        })
    },
    //我的数据
    oNmyStateInfo: function(e) {
        var that = this;
        utils.http(httpUrl + "/mobile/member/my_state", {}, function(res) {
             console.log(res);
            if (res.state == 1) {
                that.setData({
                    stateInfo: res.datas
                })
            } else {
               // utils.message(res.datas)
            }
        })
    },
    //健康记事簿
    oNmyhealth: function(e) {
        var that = this;
        utils.http(httpUrl + "/mobile/member/get_health_state", {}, function(res) {
            if (res.state == 1) {
                that.setData({
                    datasList: res.datas.datas_list,
                    stateList: res.datas.state_list
                })
            } else {
                //utils.message(res.datas)
            }
        })
    },
    //新闻 查看更多
    oNNewMoreTap: function(e) {
        //1-公告，2-文章，3-视频，4-兴趣班新闻5-对比标准（个人推送新闻）
        wx.navigateTo({
            url: '../newmore/newmore?type=1',
        })
    },

    // //我的数据 标准详情
    // oNDatatitleTap: function(e) {
    //     wx.navigateTo({
    //         url: '../standardDetails/standardDetails?type=' + e.currentTarget.dataset.type
    //     })
    // },
    //我的数据 班级公告列表
    oNDatatitleTap: function (e) {
        wx.navigateTo({
            url: '../standardList/standardList'
        })
    },
    //对比标准
    oNontrastStandTap: function(e) {
        console.log(this.data.stateInfo);
         if (this.data.stateInfo==undefined){
             utils.message("您还没有对比标准的数据")
        }else{
        wx.navigateTo({
            url: '../contraststandards/contraststandards?time=' + e.currentTarget.dataset.time + "&datainfo=" + e.currentTarget.dataset.datainfo,
             })
         }
    },
    //录入情况
    oNnotepadTap: function(e) {
        wx.navigateTo({
            url: '../notepad/notepad',
        })
    },
    //我的训练
    oNmyTrainTap: function(e) {
        wx.navigateTo({
            url: '../mytrain/mytrain',
        })
    }
})